package com.wnm.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BaseServlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String uri = req.getRequestURI();
		String methodName = uri.substring(uri.lastIndexOf("/") + 1);

		Class<? extends BaseServlet> clazz = this.getClass();
		try {
			Object obj = clazz.newInstance();
			clazz.getMethod(methodName, HttpServletRequest.class, HttpServletResponse.class).invoke(obj, req, resp);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
